<?php require '../includes/security.php'; ?>
<?php require_once('../Connections/connection.php'); ?>
<?php

$id_stanza = $_GET['id_stanza'];

if (isset($_POST["Nome"])) {
  $insertSQL = "INSERT INTO oggetto (Nome, Descrizione, id_stanza, tipologia) VALUES ('".$_POST['Nome']."','<script>location.href=\"index.php?id_stanza=".$_POST['id_stanza_arrivo']."\";</script>', ".$_POST['id_stanza'].", 2)";




  mysql_select_db($database_setroma, $setroma);
  $Result1 = mysql_query($insertSQL, $setroma) or die(mysql_error());

   header("Location: aggiungi_immagine.php?id_stanza=".$id_stanza);
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
<link rel='stylesheet' type='text/css' href='../styles/style.css' />
</head>

<body>
<h1>Passo 1: inserimento titolo e descrizione</h1>
<form method="post" name="form1">
  <table >
    <tr valign="baseline">
      <td nowrap align="right">Nome:</td>
      <td><input type="text" name="Nome" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right" valign="top">Stanza:</td>
      <td>
	 
	
	<select name=id_stanza_arrivo>
	<?php
	mysql_select_db($database_setroma, $setroma);
	$query_oggetti = "SELECT * FROM stanze";
	$oggetti = mysql_query($query_oggetti, $setroma) or die(mysql_error());
	$row = mysql_fetch_assoc($oggetti);

	do {
	?>
	<option value = '<?php echo $row['id_stanza'] ?>' > <?php echo $row['Titolo'] ?>
	
	
	<?php
	} while ($row = mysql_fetch_assoc($oggetti));	
	
	
	
	?>
	  </select>
	<input type=hidden name=id_stanza value="<?php echo $id_stanza; ?>">
	
	
	  </td>
    </tr>
    <tr valign="baseline">
      <td><input type="hidden" name="abilitato" value="1" checked></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="button" value="Annulla" onclick="javascript:history.back()">   &nbsp;  <input type="submit" value="Passo 2: Inserisci Immagine ->"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</body>
</html>
